<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>

<script type="text/javascript">

	var add_form_panel = Ext.create('Ext.form.Panel', {
		//title : '上传文件',
		width : 400,
		bodyPadding : 10,
		frame : true,
		items : [ {
			xtype : 'filefield',
			name : 'Photo',
			fieldLabel : '文件',
			labelWidth : 50,
			msgTarget : 'side',
			allowBlank : false,
			anchor : '100%',
			buttonText : '选择文件'
		} ],

		buttons : [ {
			text : '上传',
			handler : function() {
				var form = this.up('form').getForm();
				if (form.isValid()) {
					form.submit({
						url : '${path}/rest/upload.htm',
						waitMsg : 'Uploading your photo...',
						success : function(fp, o) {
							Ext.Msg.alert('Success', 'Your photo "' + o.result + '" has been uploaded.');
							dataStore.load({});
							dataStore.sync();
							add_form_panel_win.hide();
						}
					});
				}
			}
		} ]
	});

	var add_form_panel_win = Ext.create("Ext.Window", {
		title : "上传文件",
		closeAction : "hide",
		items : add_form_panel
	});

	function myAdd() {
		add_form_panel.getForm().reset();
		add_form_panel_win.show();
	}
</script>
